#include "StdInc.h"
#include <assert.h>

#include "IMGShellFolder.h"

#include <sdk/MemoryUtils.stream.h>

IMGShellExtShellView::IMGShellExtShellView( IMG& imgHandle ) : refCount( 1 )
{
    this->imgHandle = std::move( imgHandle );
}

IMGShellExtShellView::~IMGShellExtShellView( void )
{
    // TODO: properly destruct shit.
    assert( this->refCount == 0 );
}

HRESULT IMGShellExtShellView::QueryInterface( REFIID riid, void **ppv )
{
    return E_NOINTERFACE;
}

ULONG IMGShellExtShellView::AddRef( void )
{
    return ++this->refCount;
}

ULONG IMGShellExtShellView::Release( void )
{
    unsigned long newRefCount = --this->refCount;

    // Do we have to delete ourselves?
    if ( newRefCount == 0 )
    {
        // Do it.
        delete this;
    }

    return newRefCount;
}

// We need a way to "manage" IDLs.
// This means allocating them and actually parsing potential IDLs.
#define IDL_REVISION    1

inline void ParseIDLFormat( LPCITEMIDLIST item )
{
    
}

HRESULT IMGShellExtShellView::BindToObject( PCUIDLIST_RELATIVE idlist, IBindCtx *bindCtx, REFIID riid, void **ppv )
{
    return E_NOTIMPL;
}

HRESULT IMGShellExtShellView::BindToStorage( PCUIDLIST_RELATIVE idlist, IBindCtx *bindCtx, REFIID riid, void **ppv )
{
    return E_NOTIMPL;
}

HRESULT IMGShellExtShellView::CompareIDs( LPARAM lParam, PCUIDLIST_RELATIVE idfirst, PCUIDLIST_RELATIVE idsecond )
{
    // This method is used to give items a default sorting.
    return E_NOTIMPL;
}

HRESULT IMGShellExtShellView::CreateViewObject( HWND wndObj, REFIID riid, void **ppv )
{
    return E_NOTIMPL;
}

HRESULT IMGShellExtShellView::EnumObjects( HWND wndObj, SHCONTF grfFlags, IEnumIDList **ppenum )
{
    return E_NOTIMPL;
}

HRESULT IMGShellExtShellView::GetAttributesOf( UINT cidl, PCUITEMID_CHILD_ARRAY apidl, SFGAOF *rgfInOut )
{
    return E_NOTIMPL;
}

HRESULT IMGShellExtShellView::GetDisplayNameOf( PCUITEMID_CHILD idl, SHGDNF uFlags, STRRET *pName )
{
    // This method is used to return a string for specific purposes of this folder.
    return E_NOTIMPL;
}

HRESULT IMGShellExtShellView::GetUIObjectOf( HWND wndObj, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, REFIID riid, UINT *rgfReserved, void **ppv )
{
    return E_NOTIMPL;
}

HRESULT IMGShellExtShellView::ParseDisplayName( HWND wndObj, IBindCtx *bindCtx, LPWSTR dispName, ULONG *pchEaten, PIDLIST_RELATIVE *ppidl, ULONG *pdwAttrib )
{
    return E_NOTIMPL;
}

HRESULT IMGShellExtShellView::SetNameOf( HWND wndObj, PCUITEMID_CHILD pidl, LPCWSTR pszName, SHGDNF uFlags, PITEMID_CHILD *ppidlOut )
{
    return E_NOTIMPL;
}

HRESULT IMGShellExtShellView::GetClassID( CLSID *clsid )
{
    *clsid = CLSID_IMGShellExtFolder;
    return S_OK;
}

HRESULT IMGShellExtShellView::Initialize( LPCITEMIDLIST pidl )
{
    // This method is used to load a serialized shell view item.
    return S_OK;
}